function intoServer(){
	showServer();
	selectContent(1);
}

function showServerConfig(text) {
	var serverConfig = JSON.parse(text);
	var urlCharsetInput = document.getElementById("urlCharset");
	urlCharsetInput.value = serverConfig.urlCharset;
	var urlCharsetSelect = document.getElementById("urlCharsetSelect");
	urlCharsetSelect.options[0].value = serverConfig.urlCharset;
	urlCharsetSelect.selectIndex = 0;
	var charsetInput = document.getElementById("charset");
	charsetInput.value = serverConfig.charset;
	var charsetSelect = document.getElementById("charsetSelect");
	charsetSelect.options[0].value = serverConfig.charset;
	charsetSelect.selectIndex = 0;
	var receiveTimeOutInput = document.getElementById("receiveTimeOut");
	receiveTimeOutInput.value = serverConfig.receiveTimeOut;
	var receiveTimeOutSelect = document.getElementById("receiveTimeOutSelect");
	receiveTimeOutSelect.options[0].value = serverConfig.receiveTimeOut;
	receiveTimeOutSelect.selectIndex = 0;
	var portInput = document.getElementById("port");
	portInput.value = serverConfig.port;
	var portSelect = document.getElementById("portSelect");
	portSelect.options[0].value = serverConfig.port;
	portSelect.selectIndex = 0;
	var classPathInput = document.getElementById("classPath");
	classPathInput.value = serverConfig.classPath;
	var classPathSelect = document.getElementById("classPathSelect");
	classPathSelect.options[0].value = serverConfig.classPath;
	classPathSelect.selectIndex = 0;
	var logSwitchInput = document.getElementById("logSwitch");
	logSwitchInput.value = serverConfig.logSwitch;
	var logSwitchSelect = document.getElementById("logSwitchSelect");
	logSwitchSelect.options[0].value = serverConfig.logSwitch;
	logSwitchSelect.selectIndex = 0;
}

function showWebProjects(text) {
	var webProjects = JSON.parse(text);
	var html = "";
	for (let i = 0; i < webProjects.length; i++) {
		html += "<span>项目</span>";
		html += "<input type=\"button\" name=\"name\" class=\"name\" onclick=\"selectProject(" + i + ")\" value=\"";
		html += webProjects[i].name;
		html += "\"/>";
		html += "<button type=\"button\" class=\"remove\" onclick=\"";
		if (webProjects[i].removable != undefined && webProjects[i].removable == false) {
			html += "forbidRemoveProject()";
		} else {
			html += "removeProject(" + i + ")";
		}
		html += "\">删</button>";
		html += "<br>";
	}
	html += "<br><button type=\"button\" class=\"add\" onclick=\"addProject()\">添加</button>";
	document.getElementById("WebProjects-context").innerHTML = html;
	if(nowProjectIndex < 0 && webProjects.length > 0){
		nowProjectIndex = 0;
	}
}

function updateServerConfig() {
	rat.qure();
	var json = {};
	json.urlCharset = document.getElementById("urlCharset").value;
	json.charset = document.getElementById("charset").value;
	json.receiveTimeOut = document.getElementById("receiveTimeOut").value;
	json.port = document.getElementById("port").value;
	json.classPath = document.getElementById("classPath").value;
	json.logSwitch = document.getElementById("logSwitch").value;
	send("POST", "/@ServerConfig", true, JSON.stringify(json), showServerConfig, null);
}

function showServer() {
	send("GET", "/@ServerConfig", true, "", showServerConfig, null);
	send("GET", "/@WebProjects", true, "", showWebProjects, null);
}

